﻿@model  FineAdmin.Model.PostsModel
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@Model.Title</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/weui/2.3.0/style/weui.min.css" rel="stylesheet">
    <link href="~/Content/css/weuix.css" rel="stylesheet" />
    <style>
        .like-trample {
            min-width: 2.5em;
            color: #576b95;
            text-align: right;
            float: right;
            margin-left: 10px;
            display: inline-block;
        }

        .weui-label-s {
            margin-left: 8px;
        }
    </style>
</head>
<body>
    <div class="weui-content">
        <div class="weui-c-inner" style="margin-bottom:67px;">
            <div class="weui-c-content">
                <h2 class="weui-c-title">@Model.Title</h2>
                <div class="weui-c-meta">
                    <span class="weui-c-nickname"><a href="javascript:;">@Model.Author</a></span>
                    @if (Model.Stime.HasValue || Model.Indate.HasValue)
                    {
                        <em class="weui-c-nickname">时限</em>
                        <em class="weui-c-nickname">

                            @Model.Stime.ToString() -  @Model.Indate.ToString()
                        </em>
                    }
                </div>
                @if (!string.IsNullOrWhiteSpace(Model.Label))
                {
                    <div class="weui-c-meta">
                        @if (Model.Label.Contains("日常"))
                        {
                            <label class="weui-label-s b-orange">日常</label>
                        }
                        @if (Model.Label.Contains("准时抢"))
                        {
                            <label class="weui-label-s b-blue f-blue">准时抢</label>
                        }
                        @if (Model.Label.Contains("推荐"))
                        {
                            <label class="weui-label-s f-green b-green">推荐</label>
                        }
                    </div>
                }
                <div class="weui-c-article">
                    @Html.Raw(Model.PostContent)
                </div>
            </div>
            <div class="weui-c-tools">
                @if (!string.IsNullOrWhiteSpace(Model.Link_To))
                {
                    <a href="@Model.Link_To">点我直达</a>
                }

                <div class="weui-c-readnum"><span class="icon icon-62"></span><span id="readnum">@Model.Clicks</span></div>
                @*<div class="weui-c-like">
                        <i class="icon"></i>
                        <span id="likenum">@Model.Likes</span>
                    </div>*@
                <div class="like-trample">
                    <span class="icon icon-65"></span>
                    <span id="likenum">@Model.Likes</span>
                </div>
                <div class="like-trample">
                    <span class="icon icon-113"></span>
                    <span id="tramplenum">@Model.Trample</span>
                </div>

            </div>
        </div>
        <div class="weui-footer weui-footer_fixed-bottom">
            <p class="weui-footer__links">
                <a href="/mobile/index" class="weui-footer__link">首页</a>
                <a href="javascript:history.go(-1)" class="weui-footer__link">返回</a>
            </p>
            <p class="weui-footer__text">Copyright © 2020-2020 HuiJi</p>
        </div>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/zepto/1.2.0/zepto.js"></script>
    <script src="~/Scripts/zepto.weui.js"></script>
    <script>
        $(function () {
            var id = "@Model.Id";
            var likes = Number("@Model.Likes");
            var Trample=Number("@Model.Trample");
            $("#likenum").click(function () {
                $.ajax({
                    type: "POST",
                    url: '../Mobile/PostsLikeAdd',
                    data: { "id": id },
                    dataType: "json",
                    beforeSend: function () {

                    },
                    success: function (rs) {
                        console.log(rs);
                        if (rs.state == "success") {
                            likes++;
                            $("#likenum").html(likes);
                            $("#likenum").addClass("pulse  animated");
                        } else {
                            $.toptip(rs.message, 2000);
                        }
                    },
                    timeout: 15000
                });
            });
            $("#tramplenum").click(function () {
                $.ajax({
                    type: "POST",
                    url: '../Mobile/PostsTrampleAdd',
                    data: { "id": id },
                    dataType: "json",
                    beforeSend: function () {

                    },
                    success: function (rs) {
                        console.log(rs);
                        if (rs.state == "success") {
                            Trample++;
                            $("#tramplenum").html(Trample);
                            $("#tramplenum").addClass("pulse  animated");
                        } else {
                            $.toptip(rs.message, 2000);
                        }
                    },
                    timeout: 15000
                });
            });

        });
    </script>
</body>
</html>
